import { Quill } from 'vue-quill-editor'

// 源码中是import直接倒入，这里要用Quill.import引入
const BlockEmbed = Quill.import('blots/block/embed')
class Image extends BlockEmbed {
  static create (value) {
    let node = super.create()
    node.setAttribute('src', value.url)
    node.setAttribute('data-index', value.dataIndex)
    node.setAttribute('data-size', value.dataSize)
    return node;
  }
 
  static value (node) {
    return {
      url: node.getAttribute('src'),
      dataIndex: node.getAttribute('data-index'),
      dataSize: node.getAttribute('data-size')
    };
  }
  
}

Image.blotName = 'image'
Image.className = 'ql-image'
Image.tagName = 'img'

export default Image